package com.fancy.learncenter.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.superservice.lya.R;

import java.io.File;
import java.util.ArrayList;

/**
 * Created by hyy on 2018/1/27.
 * Explain activity as
 */

public class AdvicePIcAdapter extends CommonRecycleViewAdapter<String> {
    public ArrayList<String> itemDatas;

    public AdvicePIcAdapter(Context mContext, ArrayList<String> itemDatas) {
        super(mContext, R.layout.advice_pic_item, itemDatas);
        this.itemDatas = itemDatas;
    }

    @Override
    public void bindView(CustomViewHold customViewHold, String item, int position) {

        SimpleDraweeView pic = customViewHold.getView(R.id.pic);


        if (position == getItemCount() - 1) {
            pic.setImageURI(item);
            customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    callBack.OnClick();
                }
            });
        } else {
            pic.setImageURI(Uri.fromFile(new File(item)));
        }

    }

    private CallBack callBack;

    public CallBack getCallBack() {
        return callBack;
    }

    public void setCallBack(CallBack callBack) {
        this.callBack = callBack;
    }

    public interface CallBack {
        abstract void OnClick();
    }


}
